package com.leetcode.algorithm.y22.m06;

/**
 * LCP 02. 分式化简
 * 
 * https://leetcode.cn/problems/deep-dark-fraction/
 * 
 * @author jie.deng
 *
 */
class QuestionLcp02Solution01 {
	
	public int[] fraction(int[] cont) {
		int[] retArr = new int[2];
		int len = cont.length;
		retArr[0] = cont[len - 1];
		retArr[1] = 1;
		for (int i = len - 2; i >= 0; i--) {
			int tmp = retArr[0];
			retArr[0] = retArr[1];
			retArr[1] = tmp;
			retArr[0] += retArr[1] * cont[i];
		}
		return retArr;
	}
    
}